﻿//打开关键词窗口
function locking(e) {
    var divLeft = e.offsetLeft;
    var divTop = e.offsetTop;
    while (e = e.offsetParent) {
        divLeft += e.offsetLeft;
        divTop += e.offsetTop;
    }
    var divObj = document.getElementById("keyWordsDiv");
    divObj.style.left = divLeft + "px";
    divObj.style.top = divTop + 20 + "px";
    divObj.style.display = "block";
}
//关闭关键词窗口
function closeSelf(word) {
    document.getElementById("keyWordsDiv").style.display = 'none';
    var objCheck = document.getElementById(word).getElementsByTagName("input");
    for (var i = 0; i < objCheck.length; i++) {
        document.getElementById(word + "_" + i).checked = false;
    }
    return false;
}
//关键词取值
function getCheckVale(word, text) {
    //var objCheck=document.getElementById("cblKeyWords");
    var objCheck = document.getElementById(word).getElementsByTagName("input");
    var objLabel = document.getElementById(word).getElementsByTagName("label")
    var txtKeyWordsValue = "";
    var m = 0
    for (var i = 0; i < objCheck.length; i++) {
        if (document.getElementById(word + "_" + i).checked) {
            var idCheck = document.getElementById(word + "_" + i).id; //当前选择checkbox的ID
            for (var j = 0; j < objLabel.length; j++) {
                var forvalue = objLabel[j].getAttributeNode("for").value
                if (forvalue == idCheck) {
                    m += 1;
                    for (var k = 0; k < m; k++) {
                        if (k == m - 1) {
                            txtKeyWordsValue += objLabel[j].innerHTML;
                        }
                        else {
                            txtKeyWordsValue += "|" + objLabel[j].innerHTML;
                            break;
                        }
                    }
                }
            }
        }
    }
    document.getElementById(text).value = txtKeyWordsValue;
    document.getElementById("keyWordsDiv").style.display = 'none';
}